#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.db import models
class Data(models.Model):
    """
    @Author: kindey
    @Date: 2025/8/7
    @Description:
    """
    id = models.AutoField(primary_key=True)
    device_id = models.IntegerField()
    data_time = models.DateTimeField()
    data_value1 = models.DecimalField(max_digits=6, decimal_places=2)
    data_value2 = models.DecimalField(max_digits=6, decimal_places=2)
    analyse = models.IntegerField(default=0)
    type = models.IntegerField(default=0)
    p = models.IntegerField(default=0)
    w = models.IntegerField(default=0)
    manual = models.IntegerField(default=0)
    giveup = models.IntegerField(default=0)
    data_value3 = models.DecimalField(max_digits=10, decimal_places=2, default=0)
    data_value4 = models.DecimalField(max_digits=10, decimal_places=2, default=0)

    class Meta:
        db_table = 'Data'
        app_label = 'source'

    def __str__(self):
        return f"Data {self.id} - Device {self.device_id}"

class DeviceDataInfo:
    def __init__(self, id, data_value, dev_type, dev_name, dev_type2, reg_name, dev_id, reg_id,data_time):
        self.id = id
        self.data_value = data_value
        self.dev_type = dev_type
        self.dev_name = dev_name
        self.dev_type2 = dev_type2
        self.reg_name = reg_name
        self.dev_id = dev_id
        self.reg_id = reg_id
        self.data_time = data_time

    class Meta:
        app_label = 'source'
